﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace Maticsoft.Web.ManagerInfo
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					int MId=(Convert.ToInt32(Request.Params["id"]));
					ShowInfo(MId);
				}
			}
		}
			
	private void ShowInfo(int MId)
	{
		Maticsoft.BLL.ManagerInfo bll=new Maticsoft.BLL.ManagerInfo();
		Maticsoft.Model.ManagerInfo model=bll.GetModel(MId);
		this.lblMId.Text=model.MId.ToString();
		this.txtMName.Text=model.MName;
		this.txtMPwd.Text=model.MPwd;
		this.txtMType.Text=model.MType.ToString();

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtMName.Text.Trim().Length==0)
			{
				strErr+="MName不能为空！\\n";	
			}
			if(this.txtMPwd.Text.Trim().Length==0)
			{
				strErr+="MPwd不能为空！\\n";	
			}
			if(!PageValidate.IsNumber(txtMType.Text))
			{
				strErr+="MType格式错误！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int MId=int.Parse(this.lblMId.Text);
			string MName=this.txtMName.Text;
			string MPwd=this.txtMPwd.Text;
			int MType=int.Parse(this.txtMType.Text);


			Maticsoft.Model.ManagerInfo model=new Maticsoft.Model.ManagerInfo();
			model.MId=MId;
			model.MName=MName;
			model.MPwd=MPwd;
			model.MType=MType;

			Maticsoft.BLL.ManagerInfo bll=new Maticsoft.BLL.ManagerInfo();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
